import time
from flask import Blueprint,Response, request
import numpy as np
import cv2

bp = Blueprint("rule",__name__,url_prefix="/rule")

@bp.route('/test')
def get_test():
    return "test"


import time

import cv2
import numpy as np
from PIL import Image
import riversr.model.u_net.predict_video as predict_video

# example: http://127.0.0.1:5555/rule/level/617.22
@bp.route('/level/<height>')
def get_speed(height):

    frame = predict_video.test()
    print("frame ok")

    frame = cv2.imencode('.jpg', frame)[1].tobytes()

    return Response(frame,mimetype="image/jpeg")

# example: http://127.0.0.1:5555/rule/level_str/1
@bp.route('/level_str/<height>')
def get_speed_str(height):

    level = predict_video.test2()

    return str(level)
    